package com.jy.rhin.facade.infra.controller.tongji;

import com.jy.common.StringUtil;
import com.jy.framework.base.entity.Result;
import com.jy.framework.base.utils.DateUtil;
import com.jy.rhin.domain.document.tongji.TongJiService;
import com.jy.rhin.sdk.dto.tongji.JieDianRZSYDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 */
@RestController
@RequestMapping("/infra/node/tongji")
@Api(tags = "前置节点首页")
@Slf4j
public class TongJiController {

    @Autowired
    private TongJiService tongJiService;


    @ApiOperation(value = "节点认证首页", notes = "节点认证首页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kaiShiRQ", value = "开始日期", required = false),
            @ApiImplicitParam(name = "jieShuRQ", value = "结束日期", required = false)
    })
    @GetMapping("/jieDianZZSY")
    public Result<JieDianRZSYDto> jieDianZZSY(@RequestParam(value = "kaiShiRQ",required = false) String kaiShiRQ,
                                              @RequestParam (value = "jieShuRQ",required = false) String jieShuRQ) {
        if(!StringUtil.isNullOrWhiteSpace(kaiShiRQ)){
            kaiShiRQ = kaiShiRQ + " 00:00:00";
        }else{
            kaiShiRQ = DateUtil.getToday() + " 00:00:00";
        }

        if(!StringUtil.isNullOrWhiteSpace(jieShuRQ)){
            jieShuRQ = jieShuRQ + " 23:59:59";
        }else{
            jieShuRQ = DateUtil.getToday() + " 00:00:00";
        }
        return  Result.success(tongJiService.jieDianZZSY(kaiShiRQ,jieShuRQ));
    }



}
